package servlet.Article;

/**
 * @program: wsn_blog
 * @description：查看文章内容
 * @author:王松年
 * @creat: 2021-07-12 16:36:20
 **/

import DAO.ArticleDAO;
import Model.Article;
import appexception.AppException;
import service.BaseService;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/detail")
public class ArticleDetailServlet extends BaseService {

    @Override
    protected void query(HttpServletRequest req, HttpServletResponse resp) throws SQLException, IOException {
        Article article = ArticleDAO.selectById(Integer.parseInt(req.getParameter("id")));
        if (article == null) {
            throw new AppException("ART002", "查询文章失败");
        }
        json.setData(article);
    }
}